<template>
  <view>
    <view @click="searchBoxHandler" class="my-search-container" :style="{'background-color': bgColor}">
      <view class="my-search-box" :style="{borderRadius: bdRadius + 'px'}">
        <uni-icons type="search" color="#666" size="17" />
        <text class="placeholder">搜索</text>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    name: "my-search",
    data() {
      return {

      };
    },
    props: {
      bgColor: {
        type: String,
        default: '#C00000'
      },
      bdRadius: {
        type: Number,
        default: 18
      }
    },
    methods: {
      searchBoxHandler(){
        this.$emit('myClick')  /* 触发 cat.vue 为此搜索组件定义的 myClick 事件*/
      }
    }
  }
</script>

<style lang="scss">
  .my-search-container {
    /* 以下三属性实现吸顶效果 */
    position: stick;
    top: 0;
    z-index: 999;
    
    // background-color: #C00000;  /* 通过组件props属性传值实现 */
    height: 50px;
    padding: 0 10px;
    display: flex;
    justify-content: center; 
    align-items: center;
  .my-search-box {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;  /* 弹性盒子元素默认宽度为内容宽度 */
      height: 36px;
      background-color: #FFFFFF;
      // border-radius: 18px;  /* 通过组件props属性传值实现 */
      
      text.placeholder {
        color: #666;
        font-size: 15px;
        margin-left: 5px;
      }
    }
  }
</style>
